-- main.lua : This program will solve algebrical problems like:
-- multiplicacao de matriz por escalar
-- multiplicacao de matrizes
-- determinantes de matrizes
-- soma e subtracao de matrizes
-- Inversão de matrizes
-- Matriz transposta
-- resolução de sistemas lineares








-- control events for main screen of the program
function generalControler(e, id, arg)

-- debug informetions only ....
--	if(arg ~= nil) then
--		gui.alert(e..' - '..id..'-'..arg)
--	else
--		gui.alert(e..' - '..id)
--	end
-- end of debug informetions only ....


	-- go to main screen
	if(e==21 and id==1) then
		sdpas.main()
	end

	-- go to credits
	if(e==21 and id==2) then
		sdpas.aboutProgram()
	end


	-- click in "ok" in credits screen
	if(e==9 and id==1801 and arg==0) then
		sdpas.main()
	end

	-- chose one of operations in list
	if(e == 12 and id==1801) then
		
		-- matrix sumn
		if(arg == 1) then
			sdpassum.main()
		end
		-- matrix substraction


	end -- end of list operations options...


end


-- declare te group of sdpas functions
sdpas = {}

function sdpas.menuDraw()

	gui.destroy()
	screen.clear()
	gui.title("SD Palm Algebra Solver")

	menus = {"Main Screen",
		 "About SDpas"}

	gui.menu(menus)
	gui.sethandler(menuSelect,generalControler)
end


function sdpas.drawInterface()
	gui.nl()
	gui.label("Chose a operation please:")
	gui.nl()
        types = {"Matriz Sum",
	         "Matriz Subtration"}

	gui.control{type="list",
		    lines=11, 
                    columns=31,
 		    list=types,
		    handler=generalControler}
	gui.nl()

end

function sdpas.aboutProgram()

	sdpas.menuDraw()

	text = "This program is a free sofware!\n"
	text = text.."Developer: Helton Eduardo Ritter\n"
	text = text.."Mail: heltonritter@gmail.com\n\n"
	text = text.."Blog: lua.sourcedreams.com.br\n"
	text = text.."Site: www.sourcedreams.com.br\n\n"
	text = text.."Thanks for use SourceDreams Palm Algebra Solver!"

	
	gui.control{type="field", lines=11, columns=30, text=text}
	gui.nl()
	gui.tab()
	gui.control{type="button", text="Ok", handler=generalControler}

end



-- the principal screen
function sdpas.main()

	sdpas.menuDraw()
	sdpas.drawInterface()	
end


sdpas.main()
gui.main()
